package my.test.mediatorpattern;

import java.util.Random;

/**
 * @author:许玉康
 * @Date: 2019/7/14 12:46
 */
public class Sale {

    public void sellIBMComputer(int number) {
        Stock stock = new Stock();
        Purchase purchase = new Purchase();
        if(stock.getStockNumber() < number) {
            purchase.buyIBMcomputer(number);
        }
        System.out.println("销售IBM电脑" + number +"台");
        stock.decrease(number);
    }

    public int getSaleStatus() {
        Random random = new Random();
        int saleStatus = random.nextInt(100);
        System.out.println("IBM电脑的销售情况为：" + saleStatus);
        return saleStatus;
    }

    public void offSale() {
        Stock stock = new Stock();
        System.out.println("折价销售IBM电脑:" + stock.getStockNumber());
    }
}
